//
//  MASExampleListVC.m
//  Masonry练习
//
//  Created by 严梦寒 on 15/10/10.
//  Copyright © 2015年 yanmenghan. All rights reserved.
//

#import "MASExampleListVC.h"
#import "BaseVC.h"
#import "horizontalScrollview.h"
#import "VerticalScrollView.h"
#import "AspectFitView.h"
#import "MarginsView.h"
#import "BaseView.h"
#import "EdgeView.h"
#import "Base2View.h"
#import "DistributeView.h"
#import "upDateButtonView.h"
#import "Example1.h"
#import "TableView.h"
#import "Masonry.h"

static NSString * const kMASCellReuseIdentifier = @"kMASCellReuseIdentifier";
@interface MASExampleListVC ()
@property (nonatomic, strong) NSArray *exampleControllers;
@property (nonatomic, strong) NSArray *finishControllers;
@end

@implementation MASExampleListVC
- (id)init{

    self = [super init];
    if(!self) return nil;
    self.title = @"Examples";
    
    self.finishControllers = @[
                               [[BaseVC alloc] initWithTitle:@"1.基本布局" viewClass:BaseView.class],
                               [[BaseVC alloc] initWithTitle:@"2.基本布局" viewClass:Base2View.class],
                               [[BaseVC alloc] initWithTitle:@"3.edge布局" viewClass:EdgeView.class],
                               [[BaseVC alloc] initWithTitle:@"4.水平ScrollView" viewClass:horizontalScrollview.class],
                               [[BaseVC alloc] initWithTitle:@"5.垂直ScrollView" viewClass:VerticalScrollView.class],
                               [[BaseVC alloc] initWithTitle:@"6.AspectFit(less使用)" viewClass:AspectFitView.class],
                               [[BaseVC alloc] initWithTitle:@"7.Margins,边缘" viewClass:MarginsView.class],
                               [[BaseVC alloc] initWithTitle:@"8.等间距布局" viewClass:DistributeView.class],
                               [[BaseVC alloc] initWithTitle:@"9.button的扩散" viewClass:upDateButtonView.class],
                              [[BaseVC alloc] initWithTitle:@"10.tableView的布局" viewClass:TableView.class],

        
                               ];
    self.exampleControllers = @[
                                
                                
                               [[BaseVC alloc] initWithTitle:@"实现" viewClass:Example1.class],
                               
                                
                                
                                ];
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self.tableView registerClass:UITableViewCell.class forCellReuseIdentifier:kMASCellReuseIdentifier];
    
    
//    [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
//
//
//    }];
    
    
//    [self.view mas_updateConstraints:^(MASConstraintMaker *make) {
//        
//    }];
    
    
//    [self.view mas_remakeConstraints:^(MASConstraintMaker *make) {
//        
//    }];
    
    
    
    //        make.left         make.leading
    //        make.right        make.trailing
    //        make.top
    //        make.bottom
    //
    //        make.size   make.width  make.height
    //
    //        make.center make.centerX make.centerY
    
    
    //        equalTo  对象类型          mas_equalTo 结构体 nsnumber包含的数字   greaterThanOrEqualTo  lessThanOrEqualTo
    
    //        inset offset
    //        multipliedBy
    //        priority
    

    
//      @[] mas_distributeViewsAlongAxis:<#(MASAxisType)#> withFixedSpacing:<#(CGFloat)#> leadSpacing:<#(CGFloat)#> tailSpacing:<#(CGFloat)#>
//    @[] mas_distributeViewsAlongAxis:<#(MASAxisType)#> withFixedItemLength:<#(CGFloat)#> leadSpacing:<#(CGFloat)#> tailSpacing:<#(CGFloat)#>
    
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 2;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    switch (section) {
        case 0:
            return @"案例";
            break;
        case 1:
            return @"参考";
            break;
        default:
            break;
    }

    return @"";

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    
    switch (section) {
        case 0:
            return self.exampleControllers.count;
            break;
        case 1:
            return self.finishControllers.count;
            break;
        default:
            break;
    }
    return 0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.section) {
        case 0:
        {
            UIViewController *viewController = self.exampleControllers[indexPath.row];
            [self.navigationController pushViewController:viewController animated:YES];
        }
            break;
        case 1:
        {
            UIViewController *viewController = self.finishControllers[indexPath.row];
            [self.navigationController pushViewController:viewController animated:YES];

        }
        
            break;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UIViewController *viewController;
    switch (indexPath.section) {
        case 0:
        {
            viewController = self.exampleControllers[indexPath.row];

        }
            break;
        case 1:
        {
            viewController = self.finishControllers[indexPath.row];
        }
            
            break;
    }
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kMASCellReuseIdentifier forIndexPath:indexPath];
    cell.textLabel.text = viewController.title;
    return cell;
}


@end
